package org.framework.lazy.cloud.network.heartbeat.server.standalone.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.LazyNettyServerRouteApplication;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.netty.server.route.*;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.dto.LazyNettyServerRouteDTO;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.netty.server.route.LazyNettyServerRoute;
import org.springframework.web.bind.annotation.*;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.spring.EasyController;

import java.util.List;

/**
 * describe 服务端路由
 *
 * @author Jia wei Wu
 * @date 2025/04/05 09:00 晚上
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyController
 **/
@Tag(name = "服务端路由提供者")
@EasyController("/lazy/netty/server/route")
public class LazyNettyServerRouteProvider {

    @Resource
    private LazyNettyServerRouteApplication lazyNettyServerRouteApplication;

    /**
     * describe 新增服务端路由
     *
     * @param lazyNettyServerRouteStoryCommand 新增服务端路由
     * @return {@link Result<LazyNettyServerRoute>} 服务端路由新增后领域对象
     * @author Jia wei Wu
     * @date 2025/04/05 09:00 晚上
     **/

    @Operation(summary = "新增服务端路由")
    @PostMapping("/story")
    public Result<LazyNettyServerRoute> story(@RequestBody LazyNettyServerRouteStoryCommand lazyNettyServerRouteStoryCommand) {
        return lazyNettyServerRouteApplication.story(lazyNettyServerRouteStoryCommand);
    }

    /**
     * describe 批量新增服务端路由
     *
     * @param lazyNettyServerRouteStoryCommandList 批量新增服务端路由
     * @return {@link Result<List<LazyNettyServerRoute>>} 服务端路由新增后领域对象集合
     * @author Jia wei Wu
     * @date 2025/04/05 09:00 晚上
     **/

    @Operation(summary = "批量新增服务端路由")
    @PostMapping("/batchStory")
    public Result<List<LazyNettyServerRoute>> batchStory(@RequestBody List<LazyNettyServerRouteStoryCommand> lazyNettyServerRouteStoryCommandList) {
        return lazyNettyServerRouteApplication.batchStory(lazyNettyServerRouteStoryCommandList);
    }

    /**
     * describe 更新服务端路由
     *
     * @param lazyNettyServerRouteUpdateCommand 更新服务端路由
     * @return {@link Result<LazyNettyServerRoute>} 服务端路由领域对象
     * @author Jia wei Wu
     * @date 2025/04/05 09:00 晚上
     **/

    @Operation(summary = "更新服务端路由")
    @PutMapping("/updateOne")
    public Result<LazyNettyServerRoute> updateOne(@RequestBody LazyNettyServerRouteUpdateCommand lazyNettyServerRouteUpdateCommand) {
        return lazyNettyServerRouteApplication.updateOne(lazyNettyServerRouteUpdateCommand);
    }

    /**
     * describe 查询单个服务端路由
     *
     * @param lazyNettyServerRouteQueryOneCommand 查询单个服务端路由
     * @return {@link Result<LazyNettyServerRouteDTO>} 服务端路由DTO对象
     * @author Jia wei Wu
     * @date 2025/04/05 09:00 晚上
     **/

    @Operation(summary = "查询单个服务端路由")
    @GetMapping("/findOne")
    public Result<LazyNettyServerRouteDTO> findOne(@ModelAttribute LazyNettyServerRouteQueryOneCommand lazyNettyServerRouteQueryOneCommand) {
        return lazyNettyServerRouteApplication.findOne(lazyNettyServerRouteQueryOneCommand);
    }

    /**
     * describe 查询多个服务端路由
     *
     * @param lazyNettyServerRouteQueryListCommand 查询多个服务端路由
     * @return {@link Result<List<LazyNettyServerRouteDTO>>} 服务端路由DTO对象
     * @author Jia wei Wu
     * @date 2025/04/05 09:00 晚上
     **/

    @Operation(summary = "查询多个服务端路由")
    @GetMapping("/findList")
    public Result<List<LazyNettyServerRouteDTO>> findList(@ModelAttribute LazyNettyServerRouteQueryListCommand lazyNettyServerRouteQueryListCommand) {
        return lazyNettyServerRouteApplication.findList(lazyNettyServerRouteQueryListCommand);
    }

    /**
     * describe 分页查询多个服务端路由
     *
     * @param lazyNettyServerRouteQueryListCommand 分页查询多个服务端路由
     * @return {@link Result<LazyPage<LazyNettyServerRouteDTO>>} 分页服务端路由DTO对象
     * @author Jia wei Wu
     * @date 2025/04/05 09:00 晚上
     **/

    @Operation(summary = "分页查询多个服务端路由")
    @GetMapping("/findPage")
    public Result<LazyPage<LazyNettyServerRouteDTO>> findPage(@Parameter(description = "分页大小") @RequestParam(defaultValue = "10", value = "size") int size,
                                                              @Parameter(description = "当前页数") @RequestParam(defaultValue = "1", value = "current") int current, @ModelAttribute LazyNettyServerRouteQueryListCommand lazyNettyServerRouteQueryListCommand) {
        return lazyNettyServerRouteApplication.findPage(size, current, lazyNettyServerRouteQueryListCommand);
    }

    /**
     * describe 删除服务端路由
     *
     * @param lazyNettyServerRouteRemoveCommand 删除服务端路由
     * @return {@link Result<LazyNettyServerRoute>} 服务端路由
     * @author Jia wei Wu
     * @date 2025/04/05 09:00 晚上
     **/

    @Operation(summary = "删除服务端路由")
    @DeleteMapping("/remove")
    public Result<LazyNettyServerRoute> remove(@ModelAttribute LazyNettyServerRouteRemoveCommand lazyNettyServerRouteRemoveCommand) {
        return lazyNettyServerRouteApplication.remove(lazyNettyServerRouteRemoveCommand);
    }
}